package com.mostromas.ess.feign;

import com.mostromas.ess.entities.SysUser;
import com.mostromas.ess.entities.UserProject;
import com.mostromas.ess.util.base.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@FeignClient(value="project-server", path = "/project")
public interface IFeignProjectController {

    @ApiOperation("Feign接口-更新软件使用期限接口")
    @PostMapping("/api/feign/effective_time")
    Result updateEffectiveTime(@RequestBody UserProject info);

    @ApiOperation("Feign接口-根据软件ID和硬件编码检验是否已经注册")
    @ApiImplicitParams({@ApiImplicitParam(name = "projectId",value = "软件ID",required = true),@ApiImplicitParam(name = "hardwareCoding",value = "硬件ID",required = true)})
    @GetMapping("/api/feign/check_register/{projectId}/{hardwareCoding}")
    int checkProjectIdHardwareCoding(@PathVariable("projectId") String projectId,@PathVariable("hardwareCoding") String hardwareCoding);

    @ApiOperation("Feign接口-根据用户名、软件ID和硬件编码检查是否能登陆")
    @ApiImplicitParams({@ApiImplicitParam(name = "username",value = "用户名",required = true),@ApiImplicitParam(name = "projectId",value = "软件ID",required = true),@ApiImplicitParam(name = "hardwareCoding",value = "硬件ID",required = true)})
    @GetMapping("/api/feign/check_login/{username}/{projectId}/{hardwareCoding}")
    UserProject getUserProject(@PathVariable("username") String username,@PathVariable("projectId") String projectId,@PathVariable("hardwareCoding") String hardwareCoding);

    @ApiImplicitParam(name="username", value="用户名", required=true)
    @ApiOperation("Feign接口-根据用户名查询所拥有的软件集合")
    @GetMapping("/api/feign/projects/{username}")
    List<UserProject> getProjectsByUsername(@PathVariable String username);

    @ApiOperation("上传文件到OSS")
    @PostMapping(value = "/api/feign/file/upload",consumes = "multipart/form-data")
    Result upload(@RequestPart("file") MultipartFile file);

    @ApiOperation("删除OOS服务器的文件")
    @ApiImplicitParam(name="fileUrl", value="要删除的文件URL", required=true)
    @DeleteMapping("/api/feign/file/delete")
    Result delete(@RequestParam(value = "fileUrl", required = false) String fileUrl);
}
